<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8" session="false" %>
<%@ page import="com.atozsoft.commonutil.Constants"%>
<%@ page import="java.util.Date"%>
<%@ page import="java.text.SimpleDateFormat"%>
	
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<!-- 
  - Author(s): houfy
  - Date: 2015-08-08 17:12:31
  - Description:
-->
<head>
<title>常用评价管理</title>
    <%@include file="/common.jsp"%>
	<%@include file="/common/common.jsp"%>
    <%@include file="/coframe/tools/skins/common.jsp" %>
	<style>
		html,body{height:100%;overflow-y:hidden}
	</style>
</head>
<body>
   <div class="search-condition">
		<div class="list">
			<div id="queryOftenOpinionForm">
				<table style="width: 100%;" class="table">
					<tr>
						<td class="tit" style="width: 120px">
							流程名称：
						</td>
						<td>
							<input class="nui-textbox " onEnter='onKeyEnter' name="criteria._expr[1].processchname"/>
	                		<input class="nui-hidden" name="criteria._expr[1]._op" value="like"/>
	                		<input class="nui-hidden" name="criteria._expr[1]._likeRule" value="all"/>
						</td>
						<td style="width: 120px">
							常用评价：
						</td>
						<td>
							<input class="nui-textbox " onEnter='onKeyEnter' name="criteria._expr[2].remark"/>
	                		<input class="nui-hidden" name="criteria._expr[2]._op" value="like"/>
	                		<input class="nui-hidden" name="criteria._expr[2]._likeRule" value="all"/>
						</td>
						<td class="btn-wrap">
							<a class="nui-button" iconCls="icon-search" onclick="search">查询</a>
						</td>
					</tr>
				</table>
				<input class="nui-hidden" name="criteria._entity"
					value="com.atozsoft.crm.dataset.crmdataset.QueryVisitRecorde" />
			</div>
		</div>
	</div>
	<div style="padding:10px 0px 0px 0px;">
		<div class="nui-toolbar" style="border-bottom:0;">
        	<table style="width:100%;">
            	<tr>
		            <td style="width:100%;">
		                <a class="nui-button" iconCls="icon-add" onclick="add()" id="add_btn">增加</a>
		            	<a class="nui-button" iconCls="icon-remove" onclick="remove()" id="delete_btn">删除</a>
		            	<a class="nui-button" iconCls="icon-help" onclick="openHelpPopup('oftenOpinion_list','常用评价一览管理')">说明</a>
		            </td>
	            </tr>
	        </table>
    	</div>
    </div>
    <div class="nui-fit">
  		<div id="oftenOpinionDataGrid" class="nui-datagrid" style="width:100%;height:99%;"
  		 url="com.atozsoft.wf.common.queryProcessOftenOpinionList.biz.ext" idField="oftenopinionid" dataField="datas"
          	sizeList=[10,20,50,100] multiSelect="true" pageSize="20" allowAlternating=true 
          	onlyCheckSelection="true">
        	<div property="columns">
          		<div type="checkcolumn" width="20px" headerAlign="center" align="center"></div>
          		<div field="oftenopinionid" width="40px" allowSort="true" align="center" headerAlign="center">
            		常用评价编号
      			</div>
          		<div field="processid" width="40px" allowSort="true" align="center" headerAlign="center">
            		流程编号
      			</div>
      			<div field="processchname" width="60px" allowSort="true" align="center" headerAlign="center">
            		流程名称
      			</div>
      			<div field="remark" allowSort="true" headerAlign="center">
            		常用评价
      			</div>
      			<div field="empname" allowSort="true" headerAlign="center"  align="center" width="40px">
            		创建人
      			</div>
      			<div field="createdate" allowSort="true" headerAlign="center" align="center" width="40px" dateFormat="yyyy-MM-dd HH:mm">
            		创建时间
      			</div>
        	</div>
      	</div>
    </div>
	<script type="text/javascript">
	    nui.parse();
	    
		var grid = nui.get("oftenOpinionDataGrid");
		
		// 初始数据
  		search();
  		
  		// 查询按钮
  		function search(){
			var form = new nui.Form("#queryOftenOpinionForm");
			var data = form.getData(true,true);
    		grid.load(data);
  			grid.sortBy("oftenopinionid", "asc");
  		}
  		
  		// 回车执行查询
  		function onKeyEnter(e) {
    		search();
  		}
  		
		 // 增加按钮
  		function add() {
            nui.open({
		        url: "<%=request.getContextPath()%>/wf/common/oftenOpinion_add.jsp?actionFlg=add",
		        title: "增加常用评价",
		        width: 540,
		        height: 240,
		        onload: function () {
		        },
		        ondestroy: function (action) {
                    grid.reload();
                }
		    });
        }
        
        // 删除按钮
        function remove() {
            var rows = grid.getSelecteds();
            
            if (rows.length > 0) {
            	nui.confirm("确认删除当前选择的常用评价？","提示",function(action){
	            	if(action!="ok") return;
	  				var json = nui.encode({oftenOpinions:rows});
	                $.ajax({
	                    url: "com.atozsoft.wf.common.deleteProcessOftenOpinion.biz.ext",
		                type: 'POST',
		                data: json,
		                cache: false,
		                contentType:'text/json',
	                    success: function (text) {
	                    	var returnJson = nui.decode(text);
							if(returnJson.resultStr == 'SUCCESS'){
								nui.alert("常用评价删除成功！", "提示");
	                        }
	                        else{
	                        	nui.alert("常用评价删除失败！", "提示");
                        	}
                        	grid.reload();
  							grid.sortBy("oftenopinionid", "asc");
	                    },
	                    error: function () {
	                    	nui.alert("常用评价删除异常！", "提示");
	                    }
	                });
                }); 
            } else {
                nui.alert("请选择一条记录！","提示");
            }
        } 

        // 初始加载  
       	$(document).ready(
       		function(){
			  	//注册查询按钮事件
			  	$(".searchbtn").click(function(){
			  		search();
			  	});
			}
		);
    </script>
</body>
</html>